Greedy method with an examples